var user_id =  GetQueryString("user_id");
$(function () {
    $("#jqGrid").jqGrid({
    	url: baseURL + 'client/manager/getCreditRecord?userId='+user_id,
        datatype: "json",
        colModel: [			
        	{ label: 'id', name: 'id', key: true,width:100,align:'center' },
			{ label: '信用分', name: 'changeValue',index:"change_value",width:155,align:'center' },
			{ label: '类型', name: 'typeContent',index:"change_type" ,width:195,align:'center',
				formatter:function(value,options,rowObject){
					if(rowObject.changeType==20){
						return rowObject.typeContent + "  -"+rowObject.changeValue+"信用分";
					}else{
						return rowObject.typeContent + "  +"+rowObject.changeValue+"信用分";
					}
				}
			},
			{ label: '时间', name: 'createTime', index:"create_time",width:180 ,align:'center'}
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50,100,200],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        autoScroll:true,
        shrinkToFit:false,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        }
        
    });
    /*创建jqGrid的操作按钮容器*/
    /*可以控制界面上增删改查的按钮是否显示*/
    //jQuery("#jqGrid").jqGrid('navGrid', '#jqGridPager', {edit : true,add : true,del : true});
    //表格宽度自适应
    $(function(){
       $(window).resize(function(){
          $("#jqGrid").setGridWidth($(window).width());
       });
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			creditStartTime: null,
			creditEndTime: null
        },
		showList: true,
		title: null,
		marketBook: {}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam', {
				postData : {
					'creditStartTime' : vm.q.creditStartTime,
					'creditEndTime' : vm.q.creditEndTime
				},
				page : page
			}).trigger("reloadGrid");
		}
	}
});